using System.Data;
using System.Data.Common;

namespace Company.BLL.DuLieuChuan
{
    public class DonViTinh : BaseClass
    {
        public static DataTable SelectAll()
        {
            string query = "SELECT * FROM t_HaiQuan_DonViTinh ORDER BY Ten";
            DbCommand dbCommand = db.GetSqlStringCommand(query);
            return db.ExecuteDataSet(dbCommand).Tables[0];
        }

        public static string GetName(object id)
        {
            string query = string.Format("SELECT * FROM t_HaiQuan_DonViTinh WHERE ID = '{0}' ORDER BY Ten", id.ToString().PadRight(3));
            DbCommand dbCommand = db.GetSqlStringCommand(query);
            IDataReader reader = db.ExecuteReader(dbCommand);
            if (reader.Read())
            {
                return reader["Ten"].ToString();
            }
            return id.ToString();
        }
    }
}